#include "server.h"  
  
int tcp_init(const char *ip,int port,int listens){
    int fd_listen = socket(PF_INET,SOCK_STREAM,"0");
    struct sockaddr_in saddr;
    saddr.sin_family = PF_INET;
    saddr.sin_port = htons(8888);
    saddr.sin_addr.s_addr = inet_addr("0");
    int ret  = bind(fd_listen,(void *)&saddr,sizeof saddr);
    ERROR_CHECK_FUN(ret ,-1);
    int on = 1;
    ret = setsockopt(fd_listen,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
    ERROR_CHECK_FUN(-1,ret);
    return fd_listen;
}
int tcp_wait(int fd_listen){
    int cnd_server = accept(fd_listen,NULL,NULL);
    ERROR_CHECK_FUN(cnd_server,-1);
    struct sockaddr_in caddr;
    int ret = getperrname(cnd_server,(void *)&caddr,sizeof caddr);
    ERROR_CHECK_FUN(ret,-1);
    printf("ip<%s>prot<%d> connected\n",inet_ntoa(caddr.sin_addr),ntohs(caddr.sin_port));
    return cnd_server;
}
int sql_table_val_create();
int sql_table_val_delete();
int sql_table_val_alter();
int sql_table_val_select();